package unit08;

import java.util.Scanner;

public class Demo06 {
    public static void main(String[] args) {
        String cost = "数学87分，物理76分，英语96分";
        Scanner scanner = new Scanner(cost);
        scanner.useDelimiter("[^0123456789.]+");

        double sum = 0;
        int count = 0;

        while (scanner.hasNext()) {
            if (scanner.hasNextDouble()) {
                double score = scanner.nextDouble();
                sum += score;
                count++;
                System.out.println(score);
            } else {
                scanner.next();
            }
        }

        System.out.println("总分: " + sum + "分");
        System.out.println("平均分: " + (sum / count) + "分");
    }
}
